<template>
  <div class="person">
    <h1>一辆{{ car.brand }}车</h1>
    <h1>价格{{ car.price }}</h1>
    <button @click="ChangePrice">修改汽车的价格</button>
    <br>
    <h2>游戏列表：</h2>
    <ul>
      <li v-for="game in games" :key="game.id">{{ game.name }}</li>
    </ul>
    <button @click="ChangeName">修改第一个游戏</button>
  </div>
</template>

<script setup name="Person">
import { reactive } from 'vue'
// 数据
let car = reactive({ brand: '奔驰', price: 100 })
let games =reactive ([
  { id: 1, name: '英雄联盟' },
  { id: 2, name: '王者荣耀' },
  { id: 3, name: '绝地求生' },
])

function ChangePrice() {
  car.price += 100
}
function ChangeName() {
  games[0].name='球球大作战'
}

</script>

<style>
.person {
  background-color: burlywood;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 10px;
}
</style>
